/**
 * Modified the table class with state= alreadyOccupied or not
 */
package cosc617_blackteam;

public class Table {

    int size;
    int id;
    boolean isEmpty; // occupied or unoccupied
    private CustomerParty cParty;

    public Table(int size, int id) {
        this.size = size;
        this.id = id;
        this.isEmpty=true;
    }

    public int getTotalSeatingSize() {
        return this.size;
    }

    public int getId() {
        return this.id;
    }public boolean setTableState(boolean currentState){
    	return currentState;

    }public boolean isEmpty(){
    	return isEmpty;
    } public CustomerParty getCustomerParty() {
        return this.cParty;
    }

    /**
     * @param cParty the customer party to add to the table.
     * @return whether the customerParty was added to the table. If the customer
     * party is larger than the table, then this will fail and return false.
     */
    public boolean addCustomerParty(CustomerParty cParty) {
        if (  cParty.getSize() <= this.size && isEmpty()) {
            this.cParty = cParty;
            isEmpty = false;
            return true;
        }
        return false;
    }
    public void setSize(int size){
    	this.size = size;
    }
    
    public void removeCustomerParty(){
    	isEmpty = true;
    	cParty = null;
    }
    
    public void setID(int id){
    	this.id = id;
    }

    /**
     *
     * @return the number of occupied seats. 0 means the table is not occupied,
     * 1+ means the table is occupied.
     */
    public int countOccupants() {
    	if(cParty != null)
    		return this.cParty.getSize();
    	else 
    		return 0;
    }
    
    public String toString(){
    
    return "Table ID: " + id + " Number of occupants: " + countOccupants() +
    		" Number of available seats: " + size;
    }
}
